<?php
	Error_Reporting(E_ALL & ~E_NOTICE);
	require_once "connect.php";

	$connect = @mysql_connect ($hostname, $username, $password);

if (!$connect) echo "Couldn't connect to db!<br>";
else 			{

$fp = fopen("export/file.txt", "w");
            mysql_select_db ($dbase, $connect);
			mysql_query ('SET CHARACTER SET cp1251', $connect);
			$sql = "SELECT  news_id, topic_id, news_header, news_text " . 
				", DATE_FORMAT(posted, '%H:%i	%d.%m.%Y') AS display_time" .
				" FROM " . $NewsTable. " where approved=1 ORDER BY posted DESC LIMIT 20";
			$result = @mysql_query ($sql, $connect);
			if (mysql_num_rows ($result) > 0) 
			{
			while (($row = mysql_fetch_array ($result)) !== False) 
			{
			$sql = "SELECT * FROM TNewsTopic WHERE topic_id=".$row ["topic_id"];
			$topic = @mysql_query ($sql, $connect);
			if (True == $topic && mysql_num_rows ($topic) == 1) $topic_name = mysql_fetch_array ($topic);
			$text = addslashes ($row["news_text"];

			$text = strip_tags ($text);
			$text = str_replace("\r\n","\r",$text); 
			$text = str_replace("\n","\r",$text); 

			$string =  $date."\t"."http://www.football-online.com.ua/index.php?section=news&id=".$row["news_id"]."\t".$text."\t".$topic_name[topic_name]."\n";

			if (fwrite ($fp, $string)) echo "Done...";
			}
			}

	}
fclose($fp); 
?>